﻿using Compass.Wasm.Shared;
using System.Net.Http.Json;
using Compass.Wasm.Shared.Plans;

namespace Compass.Wasm.Client.Services.Plans;
public interface ILessonService : IBaseService<LessonDto>
{
    //扩展查询
    Task<List<LessonDto>> GetAllByMainPlanIdAsync(Guid mainPlanId);
}
public class LessonService : BaseService<LessonDto>, ILessonService
{
    private readonly HttpClient _http;
    private const string ServiceName = "Lesson";
    public LessonService(HttpClient http) : base(http,ServiceName )
    {
        _http = http;
    }

    public async Task<List<LessonDto>> GetAllByMainPlanIdAsync(Guid mainPlanId)
    {
        var response =await _http.GetFromJsonAsync<ApiResponse<List<LessonDto>>>($"api/{ServiceName}/MainPlan/{mainPlanId}");
        return response.Status ? response.Result : new List<LessonDto>();
    }
}